(async function () {

    let Business = cookie.get('Business') ? cookie.get('Business') : null;

    //try catch 捕捉异常
    try {
        Business = JSON.parse(Business)
    } catch {
        Business = null;
    }

    if (!Business || JSON.stringify(Business) == '{}') {
        // 清空所有的cookie数据
        cookie.clear();
        mui.toast('非法登录,请先登录')
        setTimeout(() => {
            location.href = 'login.html'
        }, 1000)
        return false
    }

    let id = Business.id ?? 0;
    let mobile = Business.mobile ?? '';

    let result = await POST({
        url: 'business/check', params: {
            id: id,
            mobile: mobile
        }
    })

    //判断用户是否存在，是不是伪造的cookie信息
    if (!result && result.code == 0) {
        mui.toast(result.msg);
        cookie.clear();
        setTimeout(() => {
            location.href = 'login.html'
        }, 1000)
        return false
    }

    cookie.set('Business', JSON.stringify(result.data))

})()